package org.jeecg.modules.dashboard.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.dashboard.entity.Dashboard;

import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.Date;

/**
* @author xuganyue
* @description 针对表【pro_dashboard(首页仪表盘)】的数据库操作Mapper
* @createDate 2025-09-19 14:06:05
* @Entity org.jeecg.dashboard.entity.Dashboard
*/
@Mapper

public interface DashboardMapper extends BaseMapper<Dashboard> {

    //总供应商数量
    @Select("SELECT COUNT(*) FROM proc_supplier")
    int selectTotalSuppliersInt();

    //进行中的项目数量
    @Select("SELECT COUNT(*) FROM proc_bid WHERE bid_status = '1'")
    int selectOriginProjectsInt();

    //今日开标的数量
    @Select("SELECT COUNT(*) FROM proc_lottery WHERE create_time >= #{startTime} ")
    int selectTodayOpenTendersInt(Date startTime);

    //活跃供应商数量
    @Select("SELECT COUNT(DISTINCT supplier_id) FROM proc_supplier_evaluation WHERE update_time >= #{startTime}; ")
    int selectActiveSuppliersInt(Date startTime);

    //总计金额
    @Select("SELECT SUM(bid_price) FROM proc_bid WHERE is_winning = '1'")
    BigDecimal selectTotalAmount();
}




